﻿package site1.views.loaders
{
	import flash.display.MovieClip;
	import flash.display.Stage;
	import flash.events.Event;
	import fwk.siteManager2.LoadingDisplayer;

	import flash.utils.getDefinitionByName;

	public class LoaderClip1 extends LoadingDisplayer
	{
		private var LoaderClip : Class;
		private var _mc:MovieClip;
		
		public function LoaderClip1(stage:Stage) 
		{
			LoaderClip = getDefinitionByName("mcLoader_001") as Class;
			_mc = new LoaderClip() as MovieClip;
			
			addChild(_mc);
			
			
			_mc.addEventListener(Event.CLOSE, onCLoseEvent);
			
			super(stage);

		}
		

		override public function display():void 
		{
			
			
			_mc.gotoAndPlay("open");
			
			super.display();
		}
		
		override public function close():void 
		{
			_mc.gotoAndPlay("close");
			
		}
		private function onCLoseEvent(e:Event):void 
		{
			_mc.stop();
			super.onCloseComplete();
		}
		
		
		override public function setProgress(percent:Number, percentCurrent:Number = NaN):void 
		{
			super.setProgress(percent, percentCurrent);
			
			var sRapport:String = String(Math.ceil(percent * 100));
			if(sRapport.length == 1)
			{
				sRapport = "0" + sRapport;
			}
			//trace(sRapport);
			_mc.prct.texte.text = sRapport + "%";
			_mc.barreLoader.clip.scaleX =  percent;	
		}
		
		
		override public function setLabel(txt:String):void 
		{
			super.setLabel(txt);
		}
		

	}
	
}